<!DOCTYPE html>
<html>
<head>
    <title>Model Training</title>
</head>
<body>
    <h1>Model Training</h1>

    <form action="{{ url_for('train') }}" method="post">
        <label for="image_path">Image Path:</label>
        <input type="text" id="image_path" name="image_path" required><br>

        <label for="label_path">Label Path:</label>
        <input type="text" id="label_path" name="label_path" required><br>

        <label for="output_path">Output Path:</label>
        <input type="text" id="output_path" name="output_path" required><br>

        <button type="submit">Train Model</button>
    </form>

    <div id="result"></div>

    <script>
        document.querySelector('form').addEventListener('submit', (event) => {
            event.preventDefault();

            const formData = new FormData(event.target);

            fetch('/train', {
                method: 'POST',
                body: formData
            })
            .then(response => response.text())
            .then(data => {
                document.getElementById('result').textContent = data;
            })
            .catch(error => {
                document.getElementById('result').textContent = 'Error: ' + error;
            });
        });
    </script>
</body>
</html>